package com.tarena.lbs.business.rpc;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.business.api.BusinessApi;
import com.tarena.lbs.business.api.pojo.BusinessDto;
import com.tarena.lbs.business.pojo.vo.BusinessStoreVO;
import com.tarena.lbs.business.servcie.BusinessService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Service
@Component
@DubboService
public class BusinessApiImpl implements BusinessApi {
    @Autowired
    private BusinessService businessService;

    @Override
    public BusinessDto getBusinessById(Integer businessId) {
        BusinessStoreVO businessStoreVO = null;
        try {
            businessStoreVO = businessService.busiStoreDetail(businessId);
        } catch (BusinessException e) {
            throw new RuntimeException(e);
        }
        BusinessDto businessDto = new BusinessDto();
        BeanUtils.copyProperties(businessStoreVO,businessDto);
        return businessDto;
    }

}
